package com.tuyrk.chapter03;

import java.util.Arrays;

public class CreateThread2 {
	public static void main(String[] args) {
		Thread t = new Thread() {
			@Override
			public void run() {
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		};
		t.start();
		System.out.println(t.getThreadGroup());
		System.out.println(Thread.currentThread().getName());
		System.out.println(Thread.currentThread().getThreadGroup().getName());
		System.out.println("===========");

		ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
		System.out.println(threadGroup.activeCount());
		Thread[] threads = new Thread[threadGroup.activeCount()];
		threadGroup.enumerate(threads);
		Arrays.stream(threads).forEach(System.out::println);
	}
}
